home *** CD-ROM | disk | FTP | other *** search
- Path: news.halcyon.com!usenet
- From: normanb@halcyon.com (Norm Bryar)
- Newsgroups: comp.lang.c++
- Subject: Re: [Q] how declare a Template class as a friend
- Date: Tue, 12 Mar 1996 16:35:11 GMT
- Organization: Northwest Nexus Inc.
- Message-ID: <4i492l$qtc@news.halcyon.com>
- References: <Dnx660.1Ex@news.uwindsor.ca> <davef-1103961104160001@128.128.173.90>
- NNTP-Posting-Host: blv-pm3-ip12.halcyon.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- davef@mbl.edu (Dave Fernandes) wrote:
-
- >In article <Dnx660.1Ex@news.uwindsor.ca>, saed@engn.uwindsor.ca wrote:
-
- >> Hi all,
- >>
- >> --- How do you declare a template class to be a friend of
- >> another non-template class?
- >>
- >> template <class T> class A {}; // the template class A<T's>
- >> class B { friend class A }; // won't do it, A is not a class
- >> template <class V> class B { friend class A<V> }; // B<V's> are
- >not wanted
-
- >What if you declare your template class A as a subclass of some other
- >abstract class C, and have C be a friend of B?
-
- >class C {};
- >template <class T> class A : public C {};
- >class B {friend class C};
-
- >I'm not sure, but I think this should work.
-
- You forward declare template classes as follows:
-
- template <class T>
- class A;
-
- Have you tried the same with the friend keyword?
-
- class B
- {
- friend template <class T> class A;
- ...
- };
-
- --Norm
-
-